import cmath

def b_cylinder(data:dict):
    """
    计算斜切圆柱体，输入一个字典，返回一个字典
    :param data:字典，半径r,高h1，h2
    :return res:字典,侧面积，总面积，体积
    """
    if "r" in data and "h1" in data and "h2" in data:
        r = data["r"]
        h1 = data["h1"]
        h2 = data["h2"]
        s_cylinde=r*cmath.pi*(h1+h2)
        Surface_area=cmath.pi*r*(h1+h2+r+cmath.sqrt(r**2+(h1-h2/2)**2))
        volume = cmath.pi*r**2*(h1+h2)/2
    else:
        return {
            "error":"不能为空！"
        }
    return {
        's_cylinde':s_cylinde,
        "volume" : volume,
        "Surface_area" : Surface_area
    }


def test():
    """
    测试函数
    :return:
    """
    print(b_cylinder({"r": 2,"h1": 2,"h2":2}))


test()